{extend name="public/world"}
{block name="style"}{/block}
{block name="container"}
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            {if $allAuth}
            <div class="layui-form" lay-filter="formSearch">
                <div class="layui-field-box" style="padding:0;">
                    <div class="layui-form-item" style="margin-bottom:0">
                        <div class="layui-inline my-search">
                            <div class="layui-input-inline">
                                <select name="groupid" lay-filter="groupid">
                                    <option value="">权限所属</option>
                                    {volist name="groups" id="group"}
                                    <option value="{$key}">{$group}</option>
                                    {/volist}
                                </select>
                            </div>
                            <div class="layui-input-inline" style="width: 170px;">
                                <button type="button" class="layui-btn layui-btn-sm layui-btn-radius layui-btn-primary" title="清除条件" style="padding: 0 8px;" lay-submit lay-filter="reset"><i class="layui-icon" style="color:#009688;">&#xe640;</i></button>
                                <button type="button" class="layui-btn layui-btn-sm layui-btn-radius" lay-submit lay-filter="search">搜索</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            {/if}
            <table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/html" id="barDemo">
    {if isset($sonAuth['edit'])}
    <a href="{:url('/projects.Types/edit')}?id={{ d.id }}" class="layui-btn layui-btn-xs j-iframe-pop" lxb-data="{width: '580px', height: '425px'}" title="修改分类">修改</a>
    {/if}
</script>
<script type="text/html" id="toolbar">
    <div class="layui-btn-group fl">
        {if isset($sonAuth['add'])}
        <a href="{:url('/projects.Types/add')}" class="layui-btn layui-btn-sm layuiadmin-btn-admin j-iframe-pop" lxb-data="{width: '580px', height: '425px'}" title="添加分类">添加分类</a>
        {/if}
    </div>
</script>
<script>
    layui.use(['form','table'], function() {
        var $ = layui.jquery
            , form = layui.form
            , table = layui.table;

        form.on('submit(search)', function(){
            AtableIns.reload({
                where: form.val("formSearch"),
                page: {curr: 1}
            });
        });
        //头工具栏事件
        form.on('submit(reset)', function(){
            var searchs = form.val("formSearch");
            for (var i in searchs) {
                searchs[i] = '';
            }
            form.val("formSearch", searchs);
            AtableIns.reload({
                where: null,
                page: {curr: 1}
            });
        });
        var AtableIns = table.render({
            elem: '#dataTable'
            ,url: "{:url('/projects.Types/index')}" //数据接口
            ,where: {}
            ,page: true //开启分页
            ,skin: 'row'
            ,even: true
            ,limit: 10
            ,text: {
                none : '暂无项目'
            }
            ,toolbar: '#toolbar'
            ,defaultToolbar: false
            ,cols: [[ //表头
                {field: 'id', width: 80, title: '编号', templet: function(d){
                    return '#'+d.id;
                }}
                ,{field: 'name', width: 120, title: '分类名称'}
                ,{field: 'groups', width: 120, title: '使用部门'}
                ,{field: 'description', title: '分类描述'}
                ,{fixed: 'right', width: 120, title: '操作', templet: '#barDemo'}
            ]]
        });
    });
</script>
{/block}